<template>
	<view class="accountInformationContent">
		<commonNavBar title="证后审查"  :showSearch="true" @search="open"  ></commonNavBar>   
		<view class="centre">
			<z-paging ref="paging" autowire-list-name="subjectInformationList" autowire-query-name="listData">
				<view class="li" v-for="(list, index) in subjectInformationList" :key="index"
					@tap="subjectInformationListActive(list.id, list.companyId, list.reviewStatus)">
					<view class="float">
						<view class="left">{{ index+1 }}</view>
						<view class="right">
							<view class="" v-if="list.reviewStatus === 0">
								<text>未审查</text>
							</view>
							<view v-else>
								<text v-text="(list.fxbg == '1' || list.zgbg == '1' || list.cfdjs == '1' || list.qkzp == '1' ) ? '正常' : '异常'"></text>
							</view>
						</view>
					</view>
					<view class="dt">{{ list.companyName }}</view>
					<view class="dd">
						<view class="titles">许可证编号:</view>
						{{ list.license }}
					</view>
					<view class="dd">
						<view class="titles">监督机构:</view>
						{{ list.deptName }}
					</view>
					<view class="dd">
						<view class="titles">审查状态:</view>
						<text v-text="list.reviewStatus === 0 ? '未审查' : '已审查'"></text>
					</view>
					
					<view class="dd">
						<view class="titles">核查人员:</view>
						{{ list.checkPerson1Name }}
					</view>
					<view class="dd">
						<view class="titles">食品类别:</view>
						{{ list.businessType }}
					</view>
					<view class="dd">
						<view class="titles">审查日期:</view>
						{{ list.reviewTime ? list.reviewTime.split(' ')[0] : '' }}
					</view>
					<view class="dd" v-show="list.reviewStatus==1">
						<view class="titles">异常原因:</view>
							<text v-if="list.fxbg == '1' && list.zgbg == '1'">未上传分析报告/未上传整改报告;</text> 
						<text v-else-if="list.fxbg == '1'">分析报告上传情况;</text> 
						<text v-else-if="list.zgbg == '1'">整改报告上传情况;</text> 
					<!-- 	<text v-if="list.cfdjs == '1'">处罚决定书;</text> -->
						<text v-else-if="list.qkzp == '1'">情况照片上传情况;</text> 
					</view>
				</view>
			</z-paging>
			<uni-popup ref="popup" type="bottom" :is-mask-click="false"    >
				<view class="popupContent"  :style="{maxHeight: (scrollHeight +100) + 'px'}">
					<view class="title">高级查询</view>
					<view class="ul"   :style="{maxHeight: scrollHeight + 'px'}"> 
						<view class="li">
							<view class="left">生产经营主体：</view>
							<view class="right">
									<input type="text" placeholder="请输入生产经营主体名称" v-model="searchParam.companyName"   :border="false"  style="font-size: 13px;margin-left: -10px;"
										  placeholder-style="color:#999999:font-size:13px" />
							</view>
						</view>
						<view class="li">
							<view class="left">经营地址：</view>
							<view class="right">
									<input type="text" placeholder="请输入经营地址" v-model="searchParam.address"  style="font-size: 13px;margin-left: -10px;"  :border="false" 
										placeholder-style="color:#999999:font-size:13px"/>
							</view>
						</view>
						<view class="li"  >
							<view class="left">社会信用代码：</view>
							<view class="right">
								<input type="text" placeholder="请输入社会信用代码" v-model="searchParam.creditCode"  style="font-size: 13px;margin-left: -10px;"  :border="false" 
									placeholder-style="color:#999999:font-size:13px"/>
							</view>
						</view>
						<view class="li"  >
							<view class="left">审查状态：</view>
							<view class="right">
								<uni-data-select v-model="searchParam.reviewStatus" :localdata="reviewStatusList"
									:clear="true"></uni-data-select>
							</view>
						</view>
						<view class="li"  >
							<view class="left">年份：</view>
							<view class="right" style="display: flex;flex-direction: row;justify-content: space-between;align-items: center;width: 440rpx;">
								<picker @change="bindPickerChange" mode = "date" fields="year" :value="searchParam.checkYear"  class="search-picker" > 
									<view class="input" style="font-size: 16px;color: #000;">{{searchParam.checkYear == '' ? '请选择年份':searchParam.checkYear}}</view>
								</picker>
								<image v-if="searchParam.checkYear != ''" @tap="clearDate" src="/static/img/no.png" style="width: 14px;height: 14px;" ></image>
							</view>
						</view>
						<view class="li"  >
							<view class="left">异常类型：</view>
							<view class="right">
								<uni-data-select v-model="searchParam.abnormalType" :localdata="abnormalTypeList"
									:clear="true"></uni-data-select>
							</view>
						</view>
						<view class="li"  >
							<view class="left">审查结论：</view>
							<view class="right">
								<uni-data-select v-model="searchParam.reviewResults" :localdata="examineResultList"
									:clear="true"></uni-data-select>
							</view>
						</view>
						 
					</view>
					<view class="button">
						<button class="determine" @click="confirmBtn">确定</button>
						<button class="cancellation" @click="cancellation">取消</button>
					</view>
				</view>
			</uni-popup>
		</view>
		
	</view>
</template>

<script>
import CommonSearchCompontVue from '../../components/CommonSearchCompont.vue'
	import commonNavBar from '@/components/CommonNavBar.vue';
	
	export default {
		components:{
			commonNavBar,
			CommonSearchCompontVue
		},
		data() {
			return { 
				showSearchCompont: false,
				reviewStatusList: [{
						value: '',
						text: "全部"
					},{
						value: '0',
						text: "未审查"
					},
					{
						value: '1',
						text: "已审查"
					}
				],
				examineResultList: [{
						value: '',
						text: "全部"
					},{
						value: '1',
						text: "合格"
					},
					{
						value: '2',
						text: "基本合格"
					} ,
					{
						value: '3',
						text: "不合格"
					} 
				],
				abnormalTypeList: [{
						value: '',
						text: "全部"
					},{
						value: '1',
						text: "未上传整改报告"
					},
					{
						value: '2',
						text: "未上传分析报告"
					} ,
					{
						value: '3',
						text: "未上传情况照片"
					} 
				],
				subjectInformationList: [],
				searchParam :{
					pageNum: 1,
					pageSize: 15,
					companyName: '',
					address: '',
					creditCode: '',
					reviewStatus: '',
					checkYear: new Date().getFullYear(),
					reviewResults: '',
					abnormalType: ''
				}
			}
		},
		onReady() {
			this.$refs.paging.reload();
			this.scrollHeight = uni.getSystemInfoSync().screenHeight * 0.85 - 180
		},
		methods: {
			goBack() {
				uni.navigateBack();
			},
			open() {
				this.$refs.popup.open("bottom");
			},
			cancellation() {
				this.$refs.popup.close();
			},
			confirmBtn() {
				this.$refs.paging.reload();
				this.$refs.popup.close();
			},
			bindPickerChange(e){ 
				this.searchParam.checkYear = e.target.value;
			},
			clearDate(e){ 
				this.searchParam.checkYear = '';
			},
			async listData(pageNo, pageSize) { 
				try {
					this.searchParam.pageNum = pageNo;
					this.searchParam.pageSize= pageSize; 
					const res = await uni.$api.getList(this.searchParam);
					this.$refs.paging.complete(res.data.data);
				} catch (error) {
					this.$refs.paging.complete(false);
				}
			},
			subjectInformationListActive(id,companyId,state) {
				const  that = this;
				if(state === 1) {
					uni.navigateTo({
						url: '/pages/postCertificationReview/postCertificationReviewActive?postCertificationReviewId=' + id
					})
				}else { 
					uni.navigateTo({
						url: '/pages/postCertificationReview/postCertificationReviewActiveModify?postCertificationReviewId=' + id+ '&companyId=' + companyId 
						,events: {
							// 为指定事件添加一个监听器，获取被打开页面传送到当前页面的数据
							reloadList: function(data) {
							   that.$refs.paging.reload();
							} 
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.accountInformationContent {
		background: #F9F9F9;
		height: calc(100vh - 115rpx);

		.upper {
			position: fixed;
			z-index: 1;
			top: 0;
			left: 0;
			width: 100%;

			.title {
				background: url('../../static/img/inspectBg.png');
				background-size: cover;
				width: 100%;
				height: 115rpx;
				line-height: 115rpx;
				position: relative;
				display: flex;
				justify-content: center;

				.arrow {
					position: absolute;
					left: 33rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 100rpx;
					height: 100rpx;

					&::before {
						display: block;
						content: "";
						position: absolute;
						top: 50%;
						left: 0%;
						width: 20rpx;
						height: 20rpx;
						border-left: 1px solid #fff;
						border-top: 1px solid #fff;
						transform: translate(0%, -50%) rotate(-45deg);
					}
				}

				text {
					font-size: 30rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					letter-spacing: 1px;
				}

				.screen {
					position: absolute;
					right: 30rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 35rpx;
					height: 33rpx;
				}
			}
		}

		.centre {
			margin: 115rpx 0 0 0;
			padding: 0 17.5rpx;
			height: calc(100vh - 280rpx);
			overflow-x: hidden;

			.z-paging-content-fixed {
				padding: 115rpx 0 0 0;
			}

			.li {
				background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 100%);
				box-shadow: 0rpx 8rpx 15rpx 0rpx rgba(0, 0, 0, 0.05);
				border-radius: 15rpx;
				padding: 30rpx 30rpx 15rpx 28rpx;
				position: relative;
				margin: 13rpx 20rpx 0;

				.float {
					display: flex;
					width: 100%;
					justify-content: space-between;
					position: absolute;
					top: 0;
					left: 0;
					width: 100%;

					.left {
						padding: 0 10rpx;
						height: 46rpx;
						line-height: 46rpx;
						background: linear-gradient(180deg, #5DA1FF 0%, #0054C9 100%);
						border-radius: 11rpx 0rpx 11rpx 0rpx;
						font-size: 18rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #FFFFFF;
						text-align: center;
					}

					.right {
						padding: 0 10rpx;
						height: 46rpx;
						line-height: 46rpx;
						background: linear-gradient(180deg, #5DA1FF 0%, #0054C9 100%);
						border-radius: 0rpx 11rpx 0rpx 11rpx;
						font-size: 18rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #FFFFFF;
						text-align: center;
					}
				}

				.dt {
					font-size: 24rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 1;
					margin: 30rpx 0 14rpx 0;
				}

				.dd {
					display: flex;
					align-items: center;
					justify-content: flex-start;
					font-size: 19rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
					line-height: 1;
					margin: 12rpx auto;

					.titles {
						margin: 0 20rpx 0 0;
					}
				}
			}
		}

		.popupContent {
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 0 0;

			.uni-datetime-picker {
				width: 100%;
			}

			.title {
				width: 100%;
				height: 80rpx;
				line-height: 80rpx;
				background: url('../../static/img/popupTitle.png') no-repeat center center;
				background-size: cover;
				font-size: 25rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				text-indent: 45rpx;
			}

			.ul {

				.li {
					padding: 0 45rpx;
					margin: 0 auto;
					display: flex;
					justify-content: space-between;
					align-items: center;
					height: 68rpx;
					line-height: 68rpx;
					border-bottom: 1px solid #d6d6d6;

					.left {
						font-size: 21rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
					}

					.right {

						input {
							font-size: 21rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #999999;
							width: 460rpx;
							text-indent: 20rpx;
						} 
						picker {
							font-size: 21rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #999999;
							width: 400rpx;
							text-indent: 20rpx;
						}

						.placeholder-class {
							color: #999999;
						}

						.uni-stat__select {
							width: 460rpx;

							/deep/.uni-select {
								border: none;
							}
						}

						.uni-date {
							width: 460rpx;

							/deep/.uni-date-editor--x {
								border: none;
							}
						}
					}

					&:nth-child(odd) {
						background: #F9F9F9;
					}

					&:last-child {
						border-bottom: none;
					}
				}

				.li:last-child {
					/deep/.uni-select__selector {
						top: initial;
					}

					/deep/.uni-popper__arrow {
						display: none;
					}
				}
			}

			.button {
				margin: 58rpx auto 0;
				padding: 0 95rpx 24rpx 95rpx;
				display: flex;

				button {
					width: 269rpx;
					height: 55rpx;
					line-height: 55rpx;
					background: #0552A9;
					border-radius: 10rpx;
					font-size: 20rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;

					&.determine {
						color: #fff;
					}

					&.cancellation {
						background: none;
						border: 1rpx solid #979797;
						color: #979797;
					}
				}
			}
		}
	} 
</style>